//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using System;
using System.Collections;
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
#endif

namespace EntLibContrib.Resource.Providers.Tests
{
	[TestClass]
	public class AssemblyResourceProviderFixture
	{
		private static string resourceAssemblyName = "EntLibContrib.Resource.TestStore";
		private static string noResourceAssemblyName = "EntLibContrib.Resource.Test";
		private static string resourceBaseName = "EntLibContrib.Resource.TestStore.Properties.Resources";

		[TestMethod]
    public void CanInitializeResourceProviderFromConfigurationObjects()
    {
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider(resourceAssemblyName, resourceBaseName);
			System.Resources.ResourceManager resourceManager = assemblyResourceProvider.CreateResourceManager();

			Assert.IsNotNull(resourceManager, "The resource manager should now exist");
			Assert.AreEqual("e-World Developments Ltd", resourceManager.GetString("Ewdev"), "We should now be able to read resources");
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NullAssemblyNameThrowsException ()
		{
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider(null, resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void InvalidAssemblyNameThrowsException ()
		{
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider("invalidAssemblyName", resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void AssemblyNameWithNoResourcesThrowsException ()
		{
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider(noResourceAssemblyName, resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NullBaseNameThrowsException ()
		{
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider(resourceAssemblyName, null);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void InvalidBaseNameThrowsException ()
		{
			AssemblyResourceProvider assemblyResourceProvider = new AssemblyResourceProvider(resourceAssemblyName, "invalidBaseName");
		}
	}
}